names=['mengxl','yuhuichen','Lilu']
print(names[0])
print(names[1])
print(names[-1])
message1='we will go back again,'+names[0].title()+'.'
message2='we will go back again,'+names[1].upper()+'.'
message3='we will go back again,'+names[2].lower()+'.'
print(message1)
print(message2)
print(message3)
trans=['car','bus','train','plain','on foot']
wish='i would like to own a '+trans[-2].upper()+'.'
print(wish)
motorcycles=["honda","yamaha","suzuki"]
motorcycles.append("ducati")
print(motorcycles)
trans2=['car','bus','train','plain','on foot']
the_best_trans=trans2.pop()
wish2='the best transformation for me is '+the_best_trans.title()+'.'
print(wish2)
custmors=['lishimin','guanyinbi','lyzhi','liubang','weiqing','lijing']
invitation='i would like to have dinner with '+custmors[0]+','+custmors[1]+','+custmors[2]+','+custmors[3]+','+custmors[4]+','+custmors[5]+'.'
print(invitation)
toomuch_work="lijing"
#打印的括号里面，字符串和变量之间和变量的定义是一样的，合并到一起需要用加号
print(toomuch_work.title()+" couldn't come because of too much work.")
custmors[5]='yinzhen'
invitation2='i would like to have dinner with '+custmors[0]+','+custmors[1]+','+custmors[2]+','+custmors[3]+','+custmors[4]+','+custmors[5]+'.'
#这里错误的点是，每一条程序都是新鲜的，py不会回过头来解释之前的变量
print(invitation2)
new_invitation="i have found a larger table for dinner!so i would like to invite three more friends!"
print(new_invitation)
#方法可以直接作用与原变量当中，不需要设置新变量，并且插入方法中的第一个元素，不是方括号的列表元素
custmors.insert(0,'fangxuanling')
custmors.insert(3,'liuheng')
custmors.append('hengwen')
len(custmors)
new_invitation2='i would like to have dinner with '+custmors[0]+','+custmors[1]+','+custmors[2]+','+custmors[3]+','+custmors[4]+','+custmors[5]+','+custmors[6]+','+custmors[7]+','+custmors[8]+'.'
print(new_invitation2)
new_message='i am so sorry, i just can only invite two friends finally...'
print(new_message)
sorry_list=custmors.pop()
print('i feel so sorry,'+sorry_list+', the table can not arrive in time.')
sorry_list=custmors.pop()
print('i feel so sorry,'+sorry_list+', the table can not arrive in time.')
sorry_list=custmors.pop()
print('i feel so sorry,'+sorry_list+', the table can not arrive in time.')
sorry_list=custmors.pop()
print('i feel so sorry,'+sorry_list+', the table can not arrive in time.')
sorry_list=custmors.pop()
print('i feel so sorry,'+sorry_list+', the table can not arrive in time.')
print(custmors[0]+', you have to come with me, ok?')
print(custmors[1]+', you have to come with me, ok?')
print(custmors[2]+', you have to come with me, ok?')
print(custmors[3]+', you have to come with me, ok?')
#这里注意，删除的时候，不是按照顺序，他每次执行任务的时候每一条都是新的，所以删除也是按照一直是【0】，才能完全删除
del custmors[0]
del custmors[0]
del custmors[0]
del custmors[0]
print(custmors)
cars=['bmw','audi','toyota','subaru']
print('here is the original list:')
print(cars)
#代码中的空行在解释的时候不会空出来，如果需要就要换行符，\n
print('here si the sorted list:')
print(sorted(cars))
places=['xian','changsha','linzhi','hangzhou','shenzhen']#1
print(places)#2
print(sorted(places))#3
print(places)#4
#不管是sort还是sorted都是reverse=True，除非用别的方法，起码现阶段来说，不是函数和方法互套，而是修改参数
print(sorted(places,reverse=True))#5
print(places)#6
#reverse是方法
#print(places.reverse())#7
places.reverse()
print(places)
places.reverse()
print(places)
places.sort()#9
print(places)
places.sort(reverse=True)
print(places)#10
len(places)
#注意true，首字母大写，不然无法识别
#print(places.sort(reverse=True))打印里面不能用方法，起码现在看起来是这样的

